from flask_restplus import fields

from app.user.models import User
from utils.serializer import ModelSerializer
from .role import RoleEasySerializer
from .permission import PermissionSerializer, PermissionEasySerializer


class UserSerializer(ModelSerializer):

    class Meta:
        model = User
        fields = '__all__'


class AuthInfoSerializer(ModelSerializer):
    roles = fields.List(fields.Nested(RoleEasySerializer().fields_model()))
    permissions = fields.List(fields.Nested(PermissionEasySerializer().fields_model()))

    class Meta:
        model = User
        fields = ('id', 'name', "email", "phone", "status", "roles", "permissions")
